<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 *
 * @package  	PyroCMS
 * @subpackage  Categories
 * @category  	Module
 * @author  	PyroCMS Dev Team
 */
class Admin_Dashboard extends Admin_Controller {

	/**
	 * The current active section
	 * @access protected
	 * @var int
	 */
	protected $section = 'escort-dashboard';
	protected $_ci;
	/**
	 * The constructor
	 * @access public
	 * @return void
	 */
	public function __construct()
	{
		parent::__construct();
		$this->_ci = &get_instance();
		$this->lang->load('be_escort');
		$this->lang->load('be_escort_dashboard');
	}
	
	/**
	 * Index method, lists all categories
	 * @access public
	 * @return void
	 */
	public function index($id)
	{
		$id OR redirect('admin/be_escort');
		
		$escort = $this->_ci->escort_entity->init('id', $id);
		$user = $this->_ci->user_entity->init('id', $escort->getUserId());
		$lockedEscort = $this->_ci->locked_escort_entity->init('escort_id', $id);
		if(!$lockedEscort){
			$this->_ci->locked_escort_entity->createNewLockedEscortEntity($id);
			$lockedEscort = $this->_ci->locked_escort_entity->init('escort_id', $id);
		}
		
		if(!$escort || !$user){
			die();
		}
		$this->data['escort'] = $escort;
		$this->data['user'] = $user;
		$this->data['lockedEscort'] = $lockedEscort;
		$this->pyrocache->delete_all('modules_m');
		$this->load->view('admin/dashboard/index', $this->data);
	}
}